package com.qf.servlet;

import com.qf.service.ClassesService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;

/**
 * description: 班级删除的Servlet
 * author: Ken
 * 公众号：Java架构栈
 */
@WebServlet(urlPatterns = "/classesdelete")
public class ClassesDeleteServlet extends HttpServlet {

    private ClassesService classesService = new ClassesService();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取删除的班级id
        String[] cids = req.getParameterValues("mycheckbox");
        System.out.println("需要删除的班级id：" + Arrays.toString(cids));

        //调用业务层批量删除班级
        classesService.deleteClsByIds(cids);

        //重定向到班级列表的servlet
        resp.sendRedirect("classsequery");
    }
}
